
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 04/09/2015 16:11:35
-- Generated from EDMX file: F:\VS\Codeplex_TFS23\AccManagerKw\Model\AccManagerModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [db06bab653ffcb42bfa27aa47200b8a10f];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[CityMaster]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CityMaster];
GO
IF OBJECT_ID(N'[dbo].[CountryMaster]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CountryMaster];
GO
IF OBJECT_ID(N'[dbo].[ItemMaster]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ItemMaster];
GO
IF OBJECT_ID(N'[dbo].[ItemStock]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ItemStock];
GO
IF OBJECT_ID(N'[dbo].[StateMaster]', 'U') IS NOT NULL
    DROP TABLE [dbo].[StateMaster];
GO
IF OBJECT_ID(N'[dbo].[StoreMaster]', 'U') IS NOT NULL
    DROP TABLE [dbo].[StoreMaster];
GO
IF OBJECT_ID(N'[dbo].[UserMaster]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UserMaster];
GO
IF OBJECT_ID(N'[AccManagerModelStoreContainer].[MenuMaster]', 'U') IS NOT NULL
    DROP TABLE [AccManagerModelStoreContainer].[MenuMaster];
GO
IF OBJECT_ID(N'[AccManagerModelStoreContainer].[StockLedger]', 'U') IS NOT NULL
    DROP TABLE [AccManagerModelStoreContainer].[StockLedger];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'ItemMasters'
CREATE TABLE [dbo].[ItemMasters] (
    [ItemId] bigint  NOT NULL,
    [ItemCode] varchar(15)  NULL,
    [ItemName] varchar(100)  NULL,
    [ItemRate] decimal(18,4)  NULL,
    [ItemTypeId] bigint  NULL
);
GO

-- Creating table 'ItemStocks'
CREATE TABLE [dbo].[ItemStocks] (
    [StockId] bigint  NOT NULL,
    [ItemId] bigint  NOT NULL,
    [EntryDate] datetime  NULL,
    [Recieved] decimal(18,4)  NULL,
    [Issued] decimal(18,4)  NULL,
    [TransType] char(8)  NULL
);
GO

-- Creating table 'StoreMasters'
CREATE TABLE [dbo].[StoreMasters] (
    [StoreId] bigint  NOT NULL,
    [StoreName] nvarchar(50)  NULL,
    [Location] nvarchar(100)  NULL,
    [CityId] int  NULL,
    [CountryId] int  NULL
);
GO

-- Creating table 'UserMasters'
CREATE TABLE [dbo].[UserMasters] (
    [UserId] bigint  NOT NULL,
    [UserName] nvarchar(50)  NULL
);
GO

-- Creating table 'MenuMasters'
CREATE TABLE [dbo].[MenuMasters] (
    [MenuId] bigint  NOT NULL,
    [MenuName] nvarchar(100)  NULL,
    [ParentId] bigint  NULL,
    [Module] nchar(10)  NULL
);
GO

-- Creating table 'StockLedgers'
CREATE TABLE [dbo].[StockLedgers] (
    [StockId] bigint  NOT NULL,
    [EntryDate] datetime  NULL,
    [Received] decimal(18,4)  NULL,
    [Issued] decimal(18,4)  NULL,
    [TransType] char(8)  NULL,
    [TransId] bigint  NULL,
    [AccId] bigint  NULL
);
GO

-- Creating table 'CityMasters'
CREATE TABLE [dbo].[CityMasters] (
    [CityId] int  NOT NULL,
    [CityCode] varchar(10)  NULL,
    [CityName] varchar(50)  NULL,
    [StateId] int  NULL
);
GO

-- Creating table 'CountryMasters'
CREATE TABLE [dbo].[CountryMasters] (
    [CountryId] int  NOT NULL,
    [CountryCode] varchar(10)  NULL,
    [CountryName] varchar(50)  NULL
);
GO

-- Creating table 'StateMasters'
CREATE TABLE [dbo].[StateMasters] (
    [StateId] int  NOT NULL,
    [StateCode] varchar(10)  NULL,
    [StateName] varchar(50)  NULL,
    [CountryId] int  NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [ItemId] in table 'ItemMasters'
ALTER TABLE [dbo].[ItemMasters]
ADD CONSTRAINT [PK_ItemMasters]
    PRIMARY KEY CLUSTERED ([ItemId] ASC);
GO

-- Creating primary key on [StockId] in table 'ItemStocks'
ALTER TABLE [dbo].[ItemStocks]
ADD CONSTRAINT [PK_ItemStocks]
    PRIMARY KEY CLUSTERED ([StockId] ASC);
GO

-- Creating primary key on [StoreId] in table 'StoreMasters'
ALTER TABLE [dbo].[StoreMasters]
ADD CONSTRAINT [PK_StoreMasters]
    PRIMARY KEY CLUSTERED ([StoreId] ASC);
GO

-- Creating primary key on [UserId] in table 'UserMasters'
ALTER TABLE [dbo].[UserMasters]
ADD CONSTRAINT [PK_UserMasters]
    PRIMARY KEY CLUSTERED ([UserId] ASC);
GO

-- Creating primary key on [MenuId] in table 'MenuMasters'
ALTER TABLE [dbo].[MenuMasters]
ADD CONSTRAINT [PK_MenuMasters]
    PRIMARY KEY CLUSTERED ([MenuId] ASC);
GO

-- Creating primary key on [StockId] in table 'StockLedgers'
ALTER TABLE [dbo].[StockLedgers]
ADD CONSTRAINT [PK_StockLedgers]
    PRIMARY KEY CLUSTERED ([StockId] ASC);
GO

-- Creating primary key on [CityId] in table 'CityMasters'
ALTER TABLE [dbo].[CityMasters]
ADD CONSTRAINT [PK_CityMasters]
    PRIMARY KEY CLUSTERED ([CityId] ASC);
GO

-- Creating primary key on [CountryId] in table 'CountryMasters'
ALTER TABLE [dbo].[CountryMasters]
ADD CONSTRAINT [PK_CountryMasters]
    PRIMARY KEY CLUSTERED ([CountryId] ASC);
GO

-- Creating primary key on [StateId] in table 'StateMasters'
ALTER TABLE [dbo].[StateMasters]
ADD CONSTRAINT [PK_StateMasters]
    PRIMARY KEY CLUSTERED ([StateId] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------